//
//  ViewController.m
//  UI01_UIViewTest
//
//  Created by dllo on 16/6/4.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    
    UIButton *buttonChangeColor = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonChangeColor.tag = 1;
    buttonChangeColor.backgroundColor = [UIColor greenColor];
    buttonChangeColor.frame = CGRectMake(0, 0, 100, 50);
    [self.view addSubview:buttonChangeColor];
    
    [buttonChangeColor addTarget:self action:@selector(changeColorRandom) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *buttonChange = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonChange.backgroundColor = [UIColor redColor];
    buttonChange.frame = CGRectMake(314, 0, 100, 50);
    [self.view addSubview:buttonChange];
    
    [buttonChange addTarget:self action:@selector(changeHidden) forControlEvents:UIControlEventTouchUpInside];
    
    
    
}

-(void)changeColorRandom{
  //  UIView *findView = [self.view viewWithTag:1];
    self.view.backgroundColor = [UIColor colorWithRed:arc4random() % 255 /255.0 green:arc4random() % 255 /255.0 blue:arc4random() % 255 / 255.0 alpha:1];
}

-(void)changeHidden{
    UIButton *findButton = [self.view viewWithTag:1];
    if(findButton.hidden == YES){
        findButton.hidden = NO;
    } else {
        findButton.hidden = YES;
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
